package com.Tread;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class BankTest {
    public static final int NACCOUNTS = 100;
    public static final double INITAL_BALANCE = 1000;
    public static final double MAX_AMOUNT = 2000;
    public static String simpleDateFormat = "YYYY-MM-DD";
    SimpleDateFormat simpleDateForm = new SimpleDateFormat(simpleDateFormat);
    public static final int DELAY = 10;

    public static void main(String[] args) {
        Bank bank = new Bank(NACCOUNTS,INITAL_BALANCE);

        for (int i = 0;i < NACCOUNTS;i++){
            int fromAccount = i;
            Runnable r = () ->{
                try{
                    while (true){
                        int toAccount = (int)(bank.size() * Math.random());
                        double amount = MAX_AMOUNT * Math.random();
                        bank.transfer(fromAccount,toAccount,amount);
                        Thread.sleep((int) (100000 * Math.random()));
                    }
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            };
            Thread t = new Thread(r);

            t.start();
        }
    }


}
